//# sourceURL=http://uMapApp/UI/TopMenu/TopMenu
define([
    "mhjs/mhjs"
], function (
    mhjs
) {

    function TopMenu(option) {

        var _this = this;
        _this.isOpened = false;

        _this.ui = {
            icon : new mhjs.Img({"class": "icon"}),
            label: new mhjs.Div({"class": "label"})
        };

        mhjs.Div.call(_this, option);
        _this.addClass("menu");

        _this
            .append(_this.ui.icon)
            .append(_this.ui.label);

    }

    var _class = TopMenu;
    mhjs.Inherit(_class, mhjs.Div);


    Object.defineProperties(_class.prototype, {
        "label" : {
            set: function (label) {
                var _this = this;
                _this._label = label;
                _this.ui.label.text(label);
            },
            get: function () {
                return this._label;
            }
        },
        "icon"  : {
            set: function (icon) {
                var _this = this;
                _this._icon = icon;
                _this.ui.icon.attr("src", icon.base64 || icon);
            },
            get: function () {
                return this._icon;
            }
        },
        "module": {
            set: function (module) {
                var _this = this;
                _this._module = module;
                _this.label = _this.label || _this._module.title;
                _this.icon = _this.icon || _this._module.icon;
                module.menu = _this;

                if (_this.autoLoad) {
                    module.loadInit();
                }

            },
            get: function () {
                return this._module;
            }
        },
        "active": {
            set: function (boolean) {
                var _this = this;
                _this._active = boolean;
                _this.toggleClass("active", boolean);
            },
            get: function () {
                return this._active;
            }
        }
    });

    return _class;

});